package com.mllweb.blog.core.digest;

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
import org.springframework.util.DigestUtils;

/**
 * Base64编解码
 */
public class Base64Utils {
    /**
     * 编码
     *
     * @param binaryData
     * @return
     */
    public static String encode(byte[] binaryData) {
        return Base64.encode(binaryData);
    }

    /**
     * 解码
     *
     * @param encoded
     * @return
     * @throws Base64DecodingException
     */
    public static byte[] decode(String encoded) throws Base64DecodingException {
        return Base64.decode(encoded);
    }

    /**
     * 解码
     *
     * @param encoded
     * @return
     * @throws Base64DecodingException
     */
    public static String decodeAsHex(String encoded) throws Base64DecodingException {
        return new String(Base64.decode(encoded));
    }

}
